# /**
# * Copyright (c) 2022 Beijing Jiaotong University
# * photlab is licensed under [Open Source License].
# * You can use this software according to the terms and conditions of the [Open Source License].
# *
# * You may obtain a copy of [Open Source License] at: [https://open.source.license/]
# *
# * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# *
# * See the [Open Source License] for more details.
# */
# /**
# * Author: Shihao Xie
# * Created: Jul. 5, 2022
# * Supported by: National Key Research and Development Program of China
# */

############### Sequence Numbe Rule ####################
# Appointment: number in
# 1-10 is the photlab parameter
# 101-200 is the parameter exists in both vpi and photlab
# 201-300 is the VPIdesignSuit 11.0 parameter
# 301+ is not use yet

# thrift --gen py ./interface/graph_data_type.thrift
# thrift --gen js ./interface/graph_data_type.thrift

namespace py phot_server.rpc.graph_data_type
namespace js photlab.graph_data_type

#### Types for Rendering

enum TextAlign {
    LEFT = 0,
    RIGHT = 1,
    CENTER = 2,
}

enum PortDirection {
    IN = 0,
    OUT = 1,
    IN_OUT = 2, # not support now
}

enum Direction {
    LEFT = 0,
    DOWN = 3,
    RIGHT = 1,
    UP = 2,
}

enum PortAspect {
    LEFT = 0,
    RIGHT = 1,
    TOP = 2,
    BOTTOM = 3,
}

enum ParameterType{
    INT = 0,
    LONG = 1,
    DOUBLE = 2,
    STRING = 3,
    ENUM = 4,
    OTHER = 5
}


# edge data type that connected two component in graph
struct RenderWayPoint {
    1:required i32 x,
    2:required i32 y,
    3:required Direction direction,
}

struct RenderRoute {
    1:required i32 routeId,
    2:required list<RenderWayPoint> path,
}


# component port data type.
struct RenderPort {
    # refer to vpi parameters
    1:required i32 portId,
    2:required PortDirection direction = 2,
    3:required PortAspect aspect = 0,
    4:required i32 location = 2,
    5:required string name,
    6:required string description,
}

struct RenderRect {
    1:required i32 x = 0,
    2:required i32 y = 0,
    3:required i32 width = 4,
    4:required i32 height = 4,
}

struct RenderGraphNode {
    1:required i32 nodeId, # 等同于componentId
    2:required string componentName,
    3:required string iconName,
    4:optional string iconPath, # 新增了这个属性 下面其他属性序号+1
    5:required string description,
    6:required RenderRect rect,
    7:required list<RenderPort> ports,
}

# textbox data type
struct RenderTextArea {
    1:required i32 textId,
    2:required string text,
    3:required string textColor,
    4:required string font,
    5:required i32 fontSize,
    6:required RenderRect rect,
    10:optional TextAlign horizontalAlign,
    11:optional TextAlign verticalAlign,
    12:optional string fillColor,
    13:optional string lineColor,
    14:optional string lineWeight,
}

struct RenderGraph {
    1:required string graphId,
    2:required string graphName, # graphName 和 PhotGraph 的name 一一对应
    3:required list<RenderGraphNode> nodes,
    4:required list<RenderRoute> routes,
    5:required list<RenderTextArea> texts,
}


#### Types of model data

# parameter data type include garph server_config parameter and component parameter
struct PhotParameter{
    # photlab needed
    1:required string name,
    2:required string dataType,
    3:required string value,
    4:required string unit,
    5:required string photUnit,
    6:optional string nameTag,
    7:optional string enumItem,

    # reserved for front end
    8:optional string interval,
    9:optional string category,
    10:optional string description
}

# component data type
struct PhotComponent{
    # Compute Engine required attributes.
    1:required i32 componentId,
    2:required string name,
    3:required string calculationMethod,
    4:required string parallelComputingMethod,

    # phot support attribute
    11:required bool isAnalyzer,
    12:required bool isClass,
    13:required string description,

    # phot server search engine support
    31:required string category,
    32:required string path,

    41:required map<string, list<PhotParameter>> parameters,
}


# edge data type that connected two component in graph
struct PhotGraphLink{
    # Compute Engine required attributes.
    # linkId 和 routeId 一一对应
    1:required i32 linkId,
    2:required i32 srcNodeId,
    3:required i32 srcPortId,
    4:required i32 dstNodeId,
    5:required i32 dstPortId,
}

# graph data type
struct PhotGraph{
    1:required string graphId,
    2:required string name,
    3:required string createTime,
    4:required string author = "Photlab",
    5:required string description = "It is a Graph of Optical Fiber Communication Simulation.",
    6:required string version = "v1.0.0.1",

    7:required map<string, list<PhotParameter>> graphParameters,
    8:required list<PhotComponent> components,
    9:required list<PhotGraphLink> links

    11:optional string graphPath,
}

